#ifndef LISTWIDGET_H
#define LISTWIDGET_H

#include <QWidget>
#include <QPaintEvent>
#include <QPainter>
#include <QPushButton>
#include <QFrame>
#include <QScrollArea>
#include <QScrollBar>
#include <QHBoxLayout>
#include <QVBoxLayout>

#include <QVector>
#include <QQueue>

class ListWidget : public QWidget
{
    Q_OBJECT
public:
    struct PushButton:public QPushButton
    {
        bool remove=false;
    };
    explicit ListWidget(QWidget *parent = nullptr);
    void SetButtonStyle(PushButton*btn);
    QVector<ListWidget::PushButton*>GetCreatePlayList(){return buttons[2];};
    QStringList StringList(){return strlists;}
signals:
    void fold();//ListWidget要折叠
    void unfold();//ListWidget要展开
    void localMusicWidget();
    void myLikeWidget();
    void recommendWidget();
    void historyMusicWidget();
    void createPlayList();
    void otherPlayList(qint32 order);
    void clickedButton(qint32 order);

public slots:
    void onMainWindowResize(QSize size);
    void AddCreatePlayList(const QVector<PushButton*>&list);
    void AddFavoritePlayList(const QVector<PushButton*>&list);
    void AddCreatePlayList1(const QStringList&strlist);
public:
    QVector<QVector<PushButton*>>buttons;
private slots:
    void onClickButton(PushButton*button);
    void onClickFoldButton(PushButton*button);
    void ClearClickedStyle();
private:
    void RemoveOrInsertButton(qint64 order);
private:
    PushButton *lastClickedButton;//用来保存最后一个被按下的button，以便修改颜色
    QVector<QFrame*>frames;
    QScrollArea*scrollarea;
    QVBoxLayout*vlayout;
    QStringList strlists;
};


#endif // LISTWIDGET_H
